package com.example.leetcode;

public class HW03 {
    public static void main(String[] args) {
      //  String s ="1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,0,1";
        String s ="a,a,a,a,1,1,1,a,1,1,1,1,1,1,1,a,1";

        String cars = s
                .replaceAll(",", "");
//排序的Arrays.stream(strings).map(Integer::parseInt).sorted().collect(Collectors.toList());


        int count = 0;

        String[] split = cars.split("[a]+");
        for (String car : split) {
            int len = car.length();
            while (len > 3) {
                count++;
                len -= 3;
            }
            if (len != 0) {
                count++;
            }
        }

        System.out.println(count);
    }
       /* String[] strings = s.trim().split(",");
        int count=0;
        int sum=0;
        for (int i=0;i<strings.length;i++){
            if (strings[i].equals("0")||count>=3){
                if (count>0&&count<=3){
                    sum=sum+1;
                }
                count=0;
            }
            if (strings[i].equals("1")){
               count++;
            }

        }
        if (strings[strings.length-1].equals("1")){
            sum=sum+1;
        }
        System.out.println(sum);
    }*/
}
